package com.dgy.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.dgy.project.domain.ProjectMemberResearch;
import com.dgy.project.service.IProjectMemberResearchService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 负责人和课题组主要成员近五年重要研究课题Controller
 *
 * @author ccc
 * @date 2025-03-20
 */
@RestController
@RequestMapping("/project/research")
public class ProjectMemberResearchController extends BaseController
{
    @Autowired
    private IProjectMemberResearchService projectMemberResearchService;

    /**
     * 查询负责人和课题组主要成员近五年重要研究课题列表
     */
    @PreAuthorize("@ss.hasPermi('project:research:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectMemberResearch projectMemberResearch)
    {
        startPage();
        List<ProjectMemberResearch> list = projectMemberResearchService.selectProjectMemberResearchList(projectMemberResearch);
        return getDataTable(list);
    }

    /**
     * 导出负责人和课题组主要成员近五年重要研究课题列表
     */
    @PreAuthorize("@ss.hasPermi('project:research:export')")
    @Log(title = "负责人和课题组主要成员近五年重要研究课题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectMemberResearch projectMemberResearch)
    {
        List<ProjectMemberResearch> list = projectMemberResearchService.selectProjectMemberResearchList(projectMemberResearch);
        ExcelUtil<ProjectMemberResearch> util = new ExcelUtil<ProjectMemberResearch>(ProjectMemberResearch.class);
        util.exportExcel(response, list, "负责人和课题组主要成员近五年重要研究课题数据");
    }

    /**
     * 获取负责人和课题组主要成员近五年重要研究课题详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:research:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectMemberResearchService.selectProjectMemberResearchById(id));
    }

    /**
     * 新增负责人和课题组主要成员近五年重要研究课题
     */
    @PreAuthorize("@ss.hasPermi('project:research:add')")
    @Log(title = "负责人和课题组主要成员近五年重要研究课题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectMemberResearch projectMemberResearch)
    {
        return toAjax(projectMemberResearchService.insertProjectMemberResearch(projectMemberResearch));
    }

    /**
     * 修改负责人和课题组主要成员近五年重要研究课题
     */
    @PreAuthorize("@ss.hasPermi('project:research:edit')")
    @Log(title = "负责人和课题组主要成员近五年重要研究课题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectMemberResearch projectMemberResearch)
    {
        return toAjax(projectMemberResearchService.updateProjectMemberResearch(projectMemberResearch));
    }

    /**
     * 删除负责人和课题组主要成员近五年重要研究课题
     */
    @PreAuthorize("@ss.hasPermi('project:research:remove')")
    @Log(title = "负责人和课题组主要成员近五年重要研究课题", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectMemberResearchService.deleteProjectMemberResearchByIds(ids));
    }
}
